home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / domacnost a kancelar / scribus / scribus-1.3.3.7-win32-install.exe / lib / encodings / cp1140.py < prev    next >
Text File  |  2002-08-08  |  886b  |  45 lines

  1. """ Python Character Mapping Codec for cp1140
  2.  
  3. Written by Brian Quinlan(brian@sweetapp.com). NO WARRANTY.
  4. """
  5.  
  6. import codecs
  7. import copy
  8. import cp037
  9.  
  10. ### Codec APIs
  11.  
  12. class Codec(codecs.Codec):
  13.  
  14.     def encode(self,input,errors='strict'):
  15.  
  16.         return codecs.charmap_encode(input,errors,encoding_map)
  17.  
  18.     def decode(self,input,errors='strict'):
  19.  
  20.         return codecs.charmap_decode(input,errors,decoding_map)
  21.  
  22. class StreamWriter(Codec,codecs.StreamWriter):
  23.     pass
  24.  
  25. class StreamReader(Codec,codecs.StreamReader):
  26.     pass
  27.  
  28. ### encodings module API
  29.  
  30. def getregentry():
  31.  
  32.     return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
  33.  
  34. ### Decoding Map
  35.  
  36. decoding_map = copy.copy(cp037.decoding_map)
  37.  
  38. decoding_map.update({
  39.         0x009f: 0x20ac # EURO SIGN
  40. })
  41.  
  42. ### Encoding Map
  43.  
  44. encoding_map = codecs.make_encoding_map(decoding_map)
  45.